package rc.alfresco.users;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.log4j.Logger;
import rc.alfresco.users.dao.RcUserDao;
import rc.alfresco.users.dao.RcUserDaoIbatis;
import rc.alfresco.users.dto.RcUserTEO;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import java.io.InputStream;
import java.util.Properties;

/**
 * Created by IntelliJ IDEA.
 * User: Slejus
 * Date: 13.11.26
 * Time: 14.02
 * To change this template use File | Settings | File Templates.
 */
public class TestMain {

    private static final Logger logger = Logger.getLogger(TestMain.class);
    private static Properties props = new Properties();

    public static void main(String[] args) throws Exception
    {
        RcUserDao manager = new RcUserDaoIbatis();
        /*
        props.setProperty("db.driver","oracle.jdbc.driver.OracleDriver");
        props.setProperty("db.url","jdbc:oracle:thin:@kadadev.kada.lan:1521:kadadev");
        props.setProperty("db.username","alfresco");
        props.setProperty("db.password","alfresco");

        String resource = "sql-maps-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream, props);
        */
        SqlSessionFactoryInstance instance = new SqlSessionFactoryInstance();
        SqlSessionFactory sqlSessionFactory = instance.getSqlSessionFactoryInstance();
        SqlSession session = sqlSessionFactory.openSession();

        RcUserTEO gUser = manager.getUserByAmnId(17426579, session);
        logger.debug(gUser.getEmail());
        logger.debug(gUser.getAmnId());
        logger.debug(gUser.getId());
        logger.debug(gUser.getJobTitle());
        logger.debug(gUser.getName());
        logger.debug(gUser.getSurname());
        logger.debug(gUser.getOrganization());
    }

}
